<%-- 
	readMe:
	1.只供前台页面（除会员中心）分页调用
	2.不再使用js用form.submit的方式进行，使用直接url超链接方式

--%>
<%@ tag body-content="empty"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ tag import="com.probiz.estore.Constants" %>
<%@ attribute name="target" type="java.lang.String" required="false" description="分页提交到的网址，一般情况下默认是当前pagingUrl，一般不需要指定该参数"%>

<%
	String pagingUrl = target;
	if(null == pagingUrl){
		pagingUrl=(String)request.getAttribute(Constants.PRE_URL);
	}
	//有一定顺序
	pagingUrl = pagingUrl.replaceAll("&PrmPageNo=[0-9]\\d*","");
	pagingUrl = pagingUrl.replaceAll("\\?PrmPageNo=[0-9]\\d*&","?");		
	pagingUrl = pagingUrl.replaceAll("\\?PrmPageNo=[0-9]\\d*","");
	if(pagingUrl.indexOf("?")!=-1){
		jspContext.setAttribute("pagingUrl",pagingUrl+"&PrmPageNo");	
	}else{
		jspContext.setAttribute("pagingUrl",pagingUrl+"?PrmPageNo");
	}	
%>

<div class="pagination">
	<span title="<fmt:message key="list.paging.totalItems"/>"><fmt:message key="list.paging.total"><fmt:param><b>${sc.totalCount}</b></fmt:param></fmt:message></span>
	<span title="<fmt:message key="list.paging.currPage"/>/<fmt:message key="list.paging.totalPage"/>">&nbsp<fmt:message key="list.paging.no"/><b>${sc.pageNo}</b><fmt:message key="list.paging.slash"/><b>${sc.totalPageCount}</b><fmt:message key="list.paging.page"/></span>
	<div class="sort">
		<span><fmt:message key="list.paging.show"/>:</span>
		<div class="select_item" id="paging_size">
			<span class="value">${sc.pageSize}</span>
			<ul class="options">
				<li value="20"><b>20</b></li>	
				<li value="40"><b>40</b></li>	
				<li value="80"><b>80</b></li>	
			</ul>
		</div>
	</div>
	<input type="hidden" name="PrmItemsPerPage" id="PrmItemsPerPage"  value="${sc.pageSize}"/>
	
	<c:if test="${sc.totalPageCount>1}">
		<c:choose>
			<c:when test="${sc.pageNo<=1}">
				<a class="no_prev1" title='<fmt:message key="list.paging.prev"/>'  > </a>
			</c:when>
			<c:otherwise>
				<a class="prev1" title='<fmt:message key="list.paging.prev"/>'  href="<c:choose><c:when test="${(sc.pageNo-1) lt 1}">${pagingUrl}=1</c:when><c:otherwise>${pagingUrl}=${sc.pageNo-1}</c:otherwise></c:choose>"> </a>
			</c:otherwise>
		</c:choose>

		<c:choose>
			<c:when test="${sc.pageNo>=sc.totalPageCount}">
				<a class="no_next2" title='<fmt:message key="list.paging.next"/>'  > </a>
			</c:when>
			<c:otherwise>
				<a class="next2" title='<fmt:message key="list.paging.next"/>'  href="<c:choose><c:when test="${(sc.pageNo+1) gt sc.totalPageCount}">${pagingUrl}=${sc.totalPageCount}</c:when><c:otherwise>${pagingUrl}=${sc.pageNo+1}</c:otherwise></c:choose>"> </a>
			</c:otherwise>
		</c:choose>
	</c:if>
</div>


<script type="text/javascript">
$j(document).ready(function () {
	$j('#paging_size').hover(
		function(){
			$j(this).find('.options').show();
		},
		function(){
			$j(this).find('.options').hide();
		}		
	);
	$j('#paging_size .options li').bind('click',
		function(){
			var isChange = ($j('#PrmItemsPerPage').val() != $j(this).attr("value"));
			$j('#PrmItemsPerPage').val($j(this).attr("value"));
			$j('#paging_size .value').html($j(this).find('b').html());
			$j('#paging_size .options').hide();
			if(isChange){
				var  pagingUrl = "${pagingUrl}="+$j('#PrmPageNo').val();
				pagingUrl = pagingUrl.replace(new RegExp("&PrmItemsPerPage=[0-9]\\d*"),"");
				pagingUrl = pagingUrl.replace(new RegExp("\\?PrmItemsPerPage=[0-9]\\d*&"),"?");	
				pagingUrl = pagingUrl.replace(new RegExp("\\?PrmItemsPerPage=[0-9]\\d*"),"");
				pagingUrl += "&PrmItemsPerPage="+$j('#PrmItemsPerPage').val();
				location.href = pagingUrl;
			}
			return false;
		}
	);
});
</script>

